package com.coocaa.ops.admin.v1.panel.biz.impl;


import com.coocaa.ops.admin.v1.panel.biz.IBlockContentInfoBiz;
import com.coocaa.ops.admin.v1.panel.mapper.IBlockContentInfoMapper;
import com.coocaa.ops.common.core.base.BaseBizImpl;
import com.coocaa.ops.common.core.base.enums.ResourceStatusEnums;
import com.coocaa.ops.common.core.base.mybatis.QueryTemplate;
import com.coocaa.ops.common.core.biz.panel.entity.BlockContentInfoEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author bjh
 * @description 推荐位内容信息表-biz层接口实现
 * @date 2020-06-13 11:01:46
 */
@Service
public class  BlockContentInfoBizImpl extends BaseBizImpl<IBlockContentInfoMapper, BlockContentInfoEntity> implements IBlockContentInfoBiz {

    @Override
    public void deleteBatch(List<Integer> blockIdList) {
        if(CollectionUtils.isEmpty(blockIdList)){
            return;
        }
        getMapper().deleteBatchIds(blockIdList);
    }

    @Override
    public void logicDelBatch(List<Integer> blockIdList) {
        if(CollectionUtils.isEmpty(blockIdList)){
            return;
        }
        QueryTemplate<BlockContentInfoEntity> queryTemplate = QueryTemplate.getEqQueryTemplate("flag", 1);
        queryTemplate.lambda().in(BlockContentInfoEntity::getId, blockIdList);
        BlockContentInfoEntity update = new BlockContentInfoEntity();
        update.setFlag(ResourceStatusEnums.OFF_LINE.getStatus());
        getMapper().update(update, queryTemplate);
    }
}
